#include "include/Playlist.h"

using namespace std;

Playlist::Playlist()
   : introduction(NULL)
{
   clics[CLIC_OK] = new Source(&lecteur, "sons/clic/clic_ok.wav");
   clics[CLIC_NOK] = new Source(&lecteur, "sons/clic/clic_nok.wav");
   clics[CLIC_SEA] = new Source(&lecteur, "sons/clic/blop.wav");

   victory[NICEWORK] = new Source(&lecteur, "sons/victory/nice-work.wav");
   victory[YES1] = new Source(&lecteur, "sons/victory/yes-1.wav");
   victory[YES2] = new Source(&lecteur, "sons/victory/yes-hahahaa.wav");
   victory[UNBELIEVABLE] = new Source(&lecteur, "sons/victory/unbelievable.wav");

   defeat[BYEBYE] = new Source(&lecteur, "sons/defeat/bye-bye.wav");
   defeat[EXCUSEME] = new Source(&lecteur, "sons/defeat/excuse-me.wav");
   defeat[NEXTIME] = new Source(&lecteur, "sons/defeat/maybe-next-time-huh.wav");
   defeat[RIDICULOUS] = new Source(&lecteur, "sons/defeat/this-is-ridiculous.wav");

   roll = new Source(&lecteur, "sons/roll.wav");
}

Playlist::~Playlist()
{
   delete introduction;
//   delete []clics;
//   delete []victory;
}

void Playlist::play_volatile(Source * song)
{
   LectureRVVB::creer_volatile(song, 1, 1, 0.5);
}

void Playlist::playIntroduction()
{
   if ( !introduction )
      introduction = new Source(&lecteur, "sons/intro.wav");
   play_volatile( introduction );
   lecteur.lecture();
}

void Playlist::playClic(TypeClic _typeclic)
{
   play_volatile( clics[_typeclic] );
}

void Playlist::playVictory()
{
   srand( time(NULL) );
   play_volatile( victory[rand() % NTYPEVICTORY] );
}

void Playlist::playDefeat()
{
   srand( time(NULL) );
   play_volatile( defeat[rand() % NTYPEDEFEAT] );
}

void Playlist::playRoll()
{
   LectureRVVB::creer_volatile(roll,0.4, 1, 0.5);
}
